package com.yaozheng.vocationaltraining.service.impl;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EBean;

import com.yaozheng.vocationaltraining.iview.ITokenBaseView;
import com.yaozheng.vocationaltraining.service.CompetingProductsPKService;
import com.yaozheng.vocationaltraining.utils.Constants;
import com.yaozheng.vocationaltraining.utils.ErrorUtils;
import com.yaozheng.vocationaltraining.utils.http.okhttp.OkHttpClientManager;

@EBean
public class CompetingProductsPKServiceImpl implements
		CompetingProductsPKService {
	ITokenBaseView iTokenBaseView;

	@Override
	public void init(ITokenBaseView iTokenBaseView) {
		this.iTokenBaseView = iTokenBaseView;
	}

	@Background
	@Override
	public void list(int lastId) {
		try {
			OkHttpClientManager.getInstance().get(
					Constants.ROOTURL + "/others/pk/list?offset=" + lastId,
					iTokenBaseView.getToken(), iTokenBaseView);
		} catch (Exception e) {
			ErrorUtils.outErrorLog(e);
			if (iTokenBaseView.isResponseResult()) {
				iTokenBaseView
						.responseError(ErrorUtils.SERVER_CONNECTION_ERROR);
			}

		}
	}

}
